package asset

import (
	db "hulk-api/databases"
	"log"
)
type Asset struct {
	Ip string 		`json:"ip"`
	Hostname string		`json:"hostname"`
	System string		`json:"system"`
	Hardware string		`json:"hardware"`
	Items string		`json:"items"`
	Starus string			`json:"status"`

}

func  GetAssets() ( assets []Asset, err error) {
	//assets = make([]Asset,0)
	rows, err := db.SqlDB.Query("select ip,hostname,system,hardware,items,status from assets")
	if err != nil {
		log.Println(err)
		return
	}
	defer rows.Close()

	for rows.Next() {
		var a Asset
		rows.Scan(&a.Ip,&a.Hostname,&a.System,&a.Hardware,&a.Items,&a.Starus,)
		assets = append(assets, a)
	}
	if err = rows.Err(); err != nil {
		log.Println(err)
		return
	}
	return
}